#!/usr/bin/env bash

CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/todo_plugin.sh"

if [[ $SHELL == "/bin/zsh" ]];then
  SHE=".zshrc"
else
  SHE=".bashrc"
fi

main() {
	if [ ! -e /tmp/daemon-tmux-todo.pid ];then
	    python3 $CURRENT_DIR/scripts/daemon.py -a start
	else
	    python3 $CURRENT_DIR/scripts/daemon.py -a stop
	    python3 $CURRENT_DIR/scripts/daemon.py -a start
	fi
}

if  grep --quiet "todo_plugin.sh" $HOME/$SHE; then
   echo "ok";
else
   cat "$CURRENT_DIR/scripts/todo_plugin.sh" > $HOME/todo_plugin.sh;
   echo "source $HOME/todo_plugin.sh" >> $HOME/$SHE;
fi

tmux set -g status-left-length 120
main
